package com.zbkj.crmeb.task.product;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import com.zbkj.crmeb.store.service.StoreProductService;

import lombok.extern.slf4j.Slf4j;

/**
 * x
 * 随机商品排序任务,没小时一次
 * @author muyu.myw
 * @date 2020/9/27 16:29
 */
@Slf4j
@Configuration
public class ProductSortTask {
    @Value("${switch.task.ProductSortTask:true}")
    Boolean runable = true;

    @Autowired
    private StoreProductService storeProductService;

    /**
     * 统计所有品牌的商品数量，更新品牌表60分钟同步一次数据
     */
    //@XxlJob("productSortTask")
    public void runTask(){
        // 测试环境关闭了
        if(!runable){
            return;
        }
        long start = System.currentTimeMillis();
        int ct = storeProductService.reSortProduct();
        log.info("run reSort success! sortNum: {}, costTime: {}",ct,(System.currentTimeMillis()-start)/1000);
    }
}
